package com.elite.groovy.dev;

import com.elite.groovy.kh.KHUtil;
import com.elite.groovy.util.Util;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * @projectName: ngsapitask-davco
 * @package: com.elite.groovy.dev
 * @className: autoSMSTemplate
 * @author: LiJT
 * @description: TODO
 * @date: 2024-01-08 18:10
 * @version: 1.0
 */
public class autoSMSTemplate {
    private static final Logger log = LoggerFactory.getLogger(autoSMSTemplate.class);

    public static void main(String[] args) throws Exception {

        //  String sendURL = KHDBConfig.getAPIURL(eliteBean, "PA-SMS-templateUrl") + "/" + KHDBConfig.getParam(eliteBean, "SMS-SI") + "?access_token=" + access_token + "&request_id=" + String.valueOf(System.currentTimeMillis());
        String sendURL = "https://sms.yunpian.com/v2/tpl/get.json?apikey=58778defa73e383a742e24c153b84096&tpl_id=222";

        // 处理头文件
        Map<String, String> headerMap = new HashMap<String, String>();
        headerMap.put("Accept", "application/json;charset=utf-8");
        headerMap.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");

        String postResult = Util.doHttpPostUseHead(sendURL, "", "UTF-8", 120000, 0, headerMap);
        log.debug("返回请求体：" + postResult);

        JSONArray templateArr = JSONArray.fromObject(postResult);

        for (int i = 0; i < templateArr.size(); i++) {

            String tpl_id = KHUtil.GetSFJV(templateArr.getJSONObject(i), "templateID");
            String tpl_content = KHUtil.GetSFJV(templateArr.getJSONObject(i), "tpl_content");
            String check_status = KHUtil.GetSFJV(templateArr.getJSONObject(i), "check_status");
            String reason = KHUtil.GetSFJV(templateArr.getJSONObject(i), "reason");
            String lang = KHUtil.GetSFJV(templateArr.getJSONObject(i), "lang");
            String country_code = KHUtil.GetSFJV(templateArr.getJSONObject(i), "country_code");
            log.debug("处理模板tpl_id:" + tpl_id + " tpl_content:" + tpl_content);


        }
    }
}